﻿@using FFLTask.GLB.Global.Enum
@using Global.Core.ExtensionMethod
@model FFLTask.SRV.ViewModel.Shared._SearchByIdOrTitleModel
@Html.TextBoxFor(m => m.Id)
<label>@Html.RadioButtonFor(m => m.IdOrTitle, SearchBy.Title) @SearchBy.Title.GetEnumDescription()</label>
<label>@Html.RadioButtonFor(m => m.IdOrTitle, SearchBy.Id) @SearchBy.Id.GetEnumDescription() </label>
<a href="#" id="find">查找</a>
<br />
@Html.ValidationMessageFor(m => m.Id)
<div id="parentList"></div>
@if (ViewBag.ParentIsOwnOffspring != null && (bool)ViewBag.ParentIsOwnOffspring)
{
    <span class="field-validation-error">* 该父任务是当前任务的子任务</span>
}
@if (ViewBag.ShowNotFound != null && (bool)ViewBag.ShowNotFound)
{
    <span class="field-validation-error" id="not_find">* 无法找到该编号的任务</span>
}
    @*TODO: the else is necessary?*@
else
{
    <span class="field-validation-error" id="not_find" style="display: none">* 无法找到该编号的任务</span>
}
@if (Model != null && Model.Title != null)
{
    @Html.ActionLink(Model.Title, "Edit", new { taskId = Model.Id }, new { id = "parent_title" })
    <span>[@Html.ActionLink("关系", "Relation", new { taskId = Model.Id }, new { target = "_blank" })]</span>
}
<script type="text/javascript">
    $(document).ready(function () {
        $("#find").hide();
        $("#@Html.IdFor(x => x.Id)").focus(function () {
            onParentFocus($(this));
        });

        $("#find").click(function (event) {
            var taskId = $("#@Html.IdFor(x => x.Id)").val();
            var byName = $("#@Html.IdFor(m=>m.IdOrTitle):checked").val() == "@SearchBy.Title";
            findParentTask(event, taskId, byName);
        });
    });
</script>